﻿using System.Collections;
using System.Collections.Generic;

//------------------------------------------------------------
// shaco Framework
// Copyright © 2017-2021 chang.liu All rights reserved.
// Feedback: 449612236@qq.com
//------------------------------------------------------------

namespace shaco
{
    /// <summary>
    /// 游戏类管理中心
    /// </summary>
    [System.Diagnostics.DebuggerStepThrough]
    public class GameHelper : shaco.Base.GameHelper
    {
        /// <summary>
        /// Unity ui，支持任意以prefab为基础模型的ui框架
        /// </summary>
        [shaco.Base.GameInterfaceTypeAtrribute("UI Manager", "Unity")]
        static public shaco.IUIManager ui
        {
            get { if (null == _ui) _ui = GetOrSetDefaultInterface<shaco.IUIManager, shaco.UIManager>(); return _ui; }
            set { BindInterface<shaco.IUIManager>(value); _ui = value; }
        }
        static private shaco.IUIManager _ui = null;

        /// <summary>
        /// Unity ui深度管理，控制IUIManager的显示的ui层级关系
        /// </summary>
        [shaco.Base.GameInterfaceTypeAtrribute("UI Depth Change", "Unity")]
        static public shaco.IUIDepthChange uiDepth
        {
            get { if (null == _uiDepth) _uiDepth = GetOrSetDefaultInterface<shaco.IUIDepthChange, shaco.DefaultUIDepthChange>(); return _uiDepth; }
            set { BindInterface<shaco.IUIDepthChange>(value); _uiDepth = value; }
        }
        static private shaco.IUIDepthChange _uiDepth = null;

        /// <summary>
        /// Unity ui基础配置
        /// </summary>
        [shaco.Base.GameInterfaceTypeAtrribute("UI Config", "Unity")]
        static public shaco.IUIManagerConfig uiConfig
        {
            get { if (null == _uiConfig) _uiConfig = GetOrSetDefaultInterface<shaco.IUIManagerConfig, shaco.UIManagerConfig>(); return _uiConfig; }
            set { BindInterface<shaco.IUIManagerConfig>(value); _uiConfig = value; }
        }
        static private shaco.IUIManagerConfig _uiConfig = null;

        /// <summary>
        /// http下载类
        /// </summary>
        [shaco.Base.GameInterfaceTypeAtrribute("Http Downloader", "Unity")]
        static public shaco.IHttpDownLoader httpDownloader
        {
            get { if (null == _httpDownloader) _httpDownloader = GetOrSetDefaultInterface<shaco.IHttpDownLoader, shaco.HttpDownLoader>(); return _httpDownloader; }
            set { BindInterface<shaco.IHttpDownLoader>(value); _httpDownloader = value; }
        }
        static private shaco.IHttpDownLoader _httpDownloader = null;

        /// <summary>
        /// http上传类
        /// </summary>
        [shaco.Base.GameInterfaceTypeAtrribute("Http UpLoader", "Unity")]
        static public shaco.IHttpUpLoader httpUpLoader
        {
            get { if (null == _httpUpLoader) _httpUpLoader = GetOrSetDefaultInterface<shaco.IHttpUpLoader, shaco.HttpUpLoader>(); return _httpUpLoader; }
            set { BindInterface<shaco.IHttpUpLoader>(value); _httpUpLoader = value; }
        }
        static private shaco.IHttpUpLoader _httpUpLoader = null;

        /// <summary>
        /// 动画管理类
        /// </summary>
        [shaco.Base.GameInterfaceTypeAtrribute("Easy Action", "Unity")]
        static public shaco.IAction action
        {
            get { if (null == _action) _action = GetOrSetDefaultInterface<shaco.IAction, shaco.Action>(); return _action; }
            set { BindInterface<shaco.IAction>(value); _action = value; }
        }
        static private shaco.IAction _action = null;

        /// <summary>
        /// 图集配置类
        /// </summary>
        [shaco.Base.GameInterfaceTypeAtrribute("Atlas Settings", "Unity")]
        static public shaco.ISpriteAtlasSettings atlasSettings
        {
            get { if (null == _atlasSettings) _atlasSettings = GetOrSetDefaultInterface<shaco.ISpriteAtlasSettings, shaco.SpriteAtlasSettings>(); return _atlasSettings; }
            set { BindInterface<shaco.ISpriteAtlasSettings>(value); _atlasSettings = value; }
        }
        static private shaco.ISpriteAtlasSettings _atlasSettings = null;

        /// <summary>
        /// 游戏资源加载类
        /// </summary>
        [shaco.Base.GameInterfaceTypeAtrribute("Resources", "Unity")]
        static public shaco.IResources res
        {
            get { if (null == _res) _res = GetOrSetDefaultInterface<shaco.IResources, shaco.DefaultResources>(); return _res; }
            set { BindInterface<shaco.IResources>(value); _res = value; }
        }
        static private shaco.IResources _res = null;

        /// <summary>
        /// 框架内部资源加载内
        /// </summary>
        [shaco.Base.GameInterfaceTypeAtrribute("DeubgWindow", "Unity")]
        static public shaco.ICustomDebugWindow customDebugWindow
        {
            get { if (null == _customDebugWindow) _customDebugWindow = GetOrSetDefaultInterface<shaco.ICustomDebugWindow, shaco.CustomDebugWindow>(); return _customDebugWindow; }
            set { BindInterface<shaco.ICustomDebugWindow>(value); _customDebugWindow = value; }
        }
        static private shaco.ICustomDebugWindow _customDebugWindow = null;

        /// <summary>
        /// 开启一个协程方法(全局)
        /// <param name="routine">协程方法</param>
        /// <return>协程返回值</return>
        /// </summary>
        static public void StartCoroutine(IEnumerator routine)
        {
            coroutine.StartCoroutine(routine);
        }

        /// <summary>
        /// 关闭一个协程方法(全局)
        /// <param name="routine">协程方法</param>
        /// <return>协程返回值</return>
        /// </summary>
        static public void StopCoroutine(IEnumerator routine)
        {
            coroutine.StopCoroutine(routine);
        }
    }
}